''
'' DotNetNuke -  http://www.dotnetnuke.com
'' Copyright (c) 2002-2004
'' by Shaun Walker ( sales@perpetualmotion.ca ) of Perpetual Motion Interactive Systems Inc. ( http://www.perpetualmotion.ca )
''
'' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
'' documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
'' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
'' to permit persons to whom the Software is furnished to do so, subject to the following conditions:
''
'' The above copyright notice and this permission notice shall be included in all copies or substantial portions 
'' of the Software.
''
'' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
'' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
'' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
'' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
'' DEALINGS IN THE SOFTWARE.
''

'Imports System
'Imports System.Web.UI
'Imports System.Web.UI.WebControls
'Imports System.Diagnostics
'Namespace DotNetNuke.UI.WebControls

'	Friend Class TreeNodeUpLevelWriter
'		Implements ITreeNodeWriter
'		Shared ReadOnly _expcol As String() = New String(1) {"+", "-"}
'		Private _Node As TreeNode

'		''' -----------------------------------------------------------------------------
'		''' <summary>
'		''' 
'		''' </summary>
'		''' <param name="writer"></param>
'		''' <param name="Node"></param>
'		''' <remarks>
'		''' </remarks>
'		''' <history>
'		''' 	[jbrinkman]	5/6/2004	Created
'		''' </history>
'		''' -----------------------------------------------------------------------------
'		Public Sub RenderNode(ByVal writer As HtmlTextWriter, ByVal Node As TreeNode) Implements ITreeNodeWriter.RenderNode
'			_Node = Node
'			Render(writer)
'		End Sub

'		''' -----------------------------------------------------------------------------
'		''' <summary>
'		''' 
'		''' </summary>
'		''' <param name="writer"></param>
'		''' <remarks>
'		''' </remarks>
'		''' <history>
'		''' 	[jbrinkman]	5/6/2004	Created
'		''' </history>
'		''' -----------------------------------------------------------------------------
'		Protected Sub Render(ByVal writer As HtmlTextWriter)
'			RenderContents(writer)
'			If _Node.HasNodes Then
'				writer.AddAttribute(HtmlTextWriterAttribute.Class, "Child")
'				writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%")
'				RenderChildren(writer)
'			End If
'		End Sub

'		''' -----------------------------------------------------------------------------
'		''' <summary>
'		''' 
'		''' </summary>
'		''' <param name="writer"></param>
'		''' <remarks>
'		''' </remarks>
'		''' <history>
'		''' 	[jbrinkman]	5/6/2004	Created
'		''' </history>
'		''' -----------------------------------------------------------------------------
'		Protected Sub RenderContents(ByVal writer As HtmlTextWriter)

'			RenderOpenTag(writer)

'			If _Node.Level > 0 AndAlso _Node.DNNTree.IndentWidth > 0 Then
'				RenderSpacer(writer, _Node.Level * _Node.DNNTree.IndentWidth)
'			End If

'			RenderExpandNodeIcon(writer)

'			RenderNodeCheckbox(writer)

'			RenderNodeIcon(writer)

'			RenderNodeText(writer)

'			writer.RenderEndTag()

'		End Sub

'		''' -----------------------------------------------------------------------------
'		''' <summary>
'		''' 
'		''' </summary>
'		''' <param name="writer"></param>
'		''' <remarks>
'		''' </remarks>
'		''' <history>
'		''' 	[jbrinkman]	5/6/2004	Created
'		''' </history>
'		''' -----------------------------------------------------------------------------
'		Protected Sub RenderOpenTag(ByVal writer As HtmlTextWriter)
'			Dim NodeClass As String = "Node"

'			If Len(_Node.CssClass) > 0 Then
'				NodeClass = _Node.CssClass
'			ElseIf Len(_Node.DNNTree.DefaultNodeCssClass) > 0 Then
'				NodeClass = _Node.DNNTree.DefaultNodeCssClass
'			End If

'			writer.AddAttribute(HtmlTextWriterAttribute.Class, NodeClass)
'			writer.AddAttribute(HtmlTextWriterAttribute.Name, _Node.ID)
'			writer.AddAttribute(HtmlTextWriterAttribute.Id, _Node.ID.Replace(_Node._separator, "_"))
'			writer.RenderBeginTag(HtmlTextWriterTag.Div)
'		End Sub

'		''' -----------------------------------------------------------------------------
'		''' <summary>
'		''' 
'		''' </summary>
'		''' <param name="writer"></param>
'		''' <remarks>
'		''' </remarks>
'		''' <history>
'		''' 	[jbrinkman]	5/6/2004	Created
'		''' </history>
'		''' -----------------------------------------------------------------------------
'		Protected Sub RenderExpandNodeIcon(ByVal writer As HtmlTextWriter)
'			If _Node.HasNodes Then
'				Dim _link As HyperLink = New HyperLink
'				Dim _image As Image = New Image
'				If _Node.IsExpanded Then
'					_link.Text = _expcol(1)
'					If Len(_Node.DNNTree.ExpandedNodeImage) > 0 Then
'						_image.ImageUrl = _Node.DNNTree.ExpandedNodeImage
'					End If
'				Else
'					_link.Text = _expcol(0)
'					If Len(_Node.DNNTree.CollapsedNodeImage) > 0 Then
'						_image.ImageUrl = _Node.DNNTree.CollapsedNodeImage
'					End If
'				End If

'				_link.ID = NodeClientID("l")
'				_image.ID = NodeClientID("i")
'				_link.NavigateUrl = "javascript:__dt_ExpandClick('" & NodeClientID("") & "', '" & _Node.DNNTree.ClientID & "');"
'				If Len(_image.ImageUrl) > 0 Then
'					_link.RenderBeginTag(writer)
'					_image.RenderControl(writer)
'					_link.RenderEndTag(writer)
'				Else
'					_link.RenderControl(writer)
'				End If
'				_image = Nothing
'				_link = Nothing
'			Else
'				RenderSpacer(writer, 9)
'			End If
'			writer.Write("&nbsp;")
'		End Sub

'		''' -----------------------------------------------------------------------------
'		''' <summary>
'		''' 
'		''' </summary>
'		''' <param name="writer"></param>
'		''' <remarks>
'		''' </remarks>
'		''' <history>
'		''' 	[jbrinkman]	5/6/2004	Created
'		''' </history>
'		''' -----------------------------------------------------------------------------
'		Protected Sub RenderNodeCheckbox(ByVal writer As HtmlTextWriter)
'			If _Node.DNNTree.CheckBoxes Then
'				Dim _checkbox As CheckBox = New CheckBox
'				_checkbox.ID = _Node.ID + TreeNode._separator + TreeNode._checkboxIDSufix
'				_checkbox.Checked = _Node.Selected
'				_checkbox.RenderControl(writer)
'				_checkbox = Nothing
'				writer.Write("&nbsp;")
'			End If
'		End Sub

'		''' -----------------------------------------------------------------------------
'		''' <summary>
'		''' 
'		''' </summary>
'		''' <param name="writer"></param>
'		''' <remarks>
'		''' </remarks>
'		''' <history>
'		''' 	[jbrinkman]	5/6/2004	Created
'		''' </history>
'		''' -----------------------------------------------------------------------------
'		Protected Sub RenderNodeIcon(ByVal writer As HtmlTextWriter)
'			If _Node.ImageIndex > -1 Then
'				Dim _NodeImage As NodeImage = _Node.DNNTree.ImageList(_Node.ImageIndex)
'				If Not (_NodeImage Is Nothing) Then
'					Dim _image As Image = New Image
'					_image.ImageUrl = _NodeImage.ImageUrl
'					_image.RenderControl(writer)
'					writer.Write("&nbsp;")
'				End If
'			End If
'		End Sub

'		''' -----------------------------------------------------------------------------
'		''' <summary>
'		''' 
'		''' </summary>
'		''' <param name="writer"></param>
'		''' <remarks>
'		''' </remarks>
'		''' <history>
'		''' 	[jbrinkman]	5/6/2004	Created
'		''' </history>
'		''' -----------------------------------------------------------------------------
'		Protected Sub RenderNodeText(ByVal writer As HtmlTextWriter)
'			'Dim _label As Label = New Label
'			Dim _link As HyperLink = New HyperLink

'			'_label.Text = _Node.Text
'			_link.Text = _Node.Text
'            _link.NavigateUrl = "javascript:__dt_TextClick('" & NodeClientID("") & "', '" & _Node.DNNTree.ClientID & "', " & CInt(_Node.ClickAction) & ");"
'			_link.ID = NodeClientID("t")

'			If Len(_Node.JSFunction) > 0 Then
'				If _Node.JSFunction.EndsWith(";") = False Then _Node.JSFunction &= ";"
'				_link.Attributes.Add("js", _Node.JSFunction)
'			End If
'			If Len(_Node.DNNTree.JSFunction) > 0 Then
'				If _Node.DNNTree.JSFunction.EndsWith(";") = False Then _Node.DNNTree.JSFunction &= ";"
'				_link.Attributes.Add("js", _Node.DNNTree.JSFunction)
'			End If

'			If Len(_Node.ToolTip) > 0 Then
'				'_label.ToolTip = _Node.ToolTip
'				_link.ToolTip = _Node.ToolTip
'			End If
'			'_label.CssClass = "NodeText"
'			'_label.RenderControl(writer)
'			If _Node.Selected Then
'				If Len(_Node.DNNTree.DefaultNodeCssClassSelected) > 0 Then _link.CssClass = _Node.DNNTree.DefaultNodeCssClassSelected
'				_link.Attributes.Add("origclass", "NodeText")
'			Else
'				_link.CssClass = "NodeText"
'			End If
'			If Len(_Node.Key) > 0 Then _link.Attributes.Add("key", _Node.Key)
'			_link.RenderControl(writer)
'		End Sub

'		''' -----------------------------------------------------------------------------
'		''' <summary>
'		''' 
'		''' </summary>
'		''' <param name="writer"></param>
'		''' <param name="Width"></param>
'		''' <remarks>
'		''' </remarks>
'		''' <history>
'		''' 	[jbrinkman]	5/6/2004	Created
'		''' </history>
'		''' -----------------------------------------------------------------------------
'		Protected Sub RenderSpacer(ByVal writer As HtmlTextWriter, ByVal Width As Integer)
'            'writer.AddStyleAttribute("width", Width.ToString & "px") 'doesn't work in mozilla?

'            writer.AddAttribute("style", "width:" & Width.ToString & "px;height:1px;")
'            writer.AddAttribute("src", _Node.DNNTree.SystemImagesPath & "spacer.gif")
'            writer.RenderBeginTag(HtmlTextWriterTag.Img)
'            writer.RenderEndTag()
'        End Sub

'        ''' -----------------------------------------------------------------------------
'        ''' <summary>
'        ''' 
'        ''' </summary>
'        ''' <param name="writer"></param>
'        ''' <remarks>
'        ''' </remarks>
'        ''' <history>
'        ''' 	[jbrinkman]	5/6/2004	Created
'        ''' </history>
'        ''' -----------------------------------------------------------------------------
'        Protected Sub RenderChildren(ByVal writer As HtmlTextWriter)
'            writer.AddAttribute("id", NodeClientID("s").Replace(":", "_"))

'            If _Node.IsExpanded = False Then
'                'writer.AddStyleAttribute("display", "none") 'doesn't work in mozilla???
'                writer.AddAttribute("style", "display:none")
'            End If

'            writer.RenderBeginTag(HtmlTextWriterTag.Span)
'            For Each _elem As TreeNode In _Node.TreeNodes
'                _elem.Render(writer)
'            Next
'            writer.RenderEndTag()
'        End Sub

'        Private Function NodeClientID(ByVal Prefix As String) As String
'            Return Prefix & _Node.ID    '.Replace(":", "_")
'        End Function
'    End Class
'End Namespace
